//
//  WBStatusCell.swift
//  SinaMicroblog
//
//  Created by 原鹏飞 on 2017/4/13.
//  Copyright © 2017年 YuanPengFei. All rights reserved.
//

import UIKit

class WBStatusCell: UITableViewCell {
    //懒加载属性: 原创微博
    lazy var originalView: WBOriginalStatusView = WBOriginalStatusView()
    //懒加载属性: 转发微博
    lazy var retweetedView: WBRetweetedStatusView = WBRetweetedStatusView()
    //懒加载属性: cell底部的toolbar
    lazy var toolbar: WBStatusToolbar = WBStatusToolbar()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        //设置UI
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


// MARK: - 设置UI
extension WBStatusCell {
    func setupUI() {
        //1. 添加子视图
        self.contentView.addSubview(originalView)
        self.contentView.addSubview(retweetedView)
        self.contentView.addSubview(toolbar)
        
        originalView.backgroundColor = UIColor.yellow
        retweetedView.backgroundColor = UIColor.red
        toolbar.backgroundColor = UIColor.gray
        
        //2. 添加约束
        originalView.snp.makeConstraints { (make) in
            make.top.left.right.equalTo(self.contentView)
//            make.height.equalTo(100)
        }
        
        retweetedView.snp.makeConstraints { (make) in
            make.top.equalTo(originalView.snp.bottom)
            make.left.right.equalTo(self.contentView)
            make.height.equalTo(100)
        }
        
        toolbar.snp.makeConstraints { (make) in
            make.top.equalTo(retweetedView.snp.bottom)
            make.height.equalTo(40)
            make.left.right.bottom.equalTo(self.contentView)
        }
    }
}
